package cartagows.wsframework.core;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.stream.XMLStreamException;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.llom.util.AXIOMUtil;

import cartagows.util.XMLib;

/**
 * Class that represent a ServiceConfiguration. So far only WS-Coordination
 * is supported. This class can be used for configure a WSInterface or a WSPanel
 * @author Andrea Santi
 *
 */
public class ServiceConfiguration implements Serializable{ 
	
	private static final long serialVersionUID = 1L;
	private String[] conf;
	private boolean configPresent;
	
		
	public ServiceConfiguration(Object... configuration){
		conf = new String[configuration.length];
		for(int i=0;i<configuration.length;i++){
			conf[i] = configuration[i].toString();
		}
		configPresent = true;
	}
		
	public OMElement[] getConfig() {
		OMElement[] headers = new OMElement[conf.length];
		for(int i=0;i<conf.length;i++){
			try {
				headers[i] = AXIOMUtil.stringToOM(conf[i]);
			} catch (XMLStreamException e) {
				e.printStackTrace();
			}
		}
		return headers;
	}
	
	public boolean isConfigPresent() {
		return configPresent;
	}
}